if defined?(::Sidekiq)

  if Trifle::Ruby::Engine.should_start_engine?(:sidekiq)
    puts "Loading Sidekiq integration" unless Trifle::Ruby::Config.is_quiet?
    require "trifle/ruby/middleware/sidekiq_job"
    Trifle::Ruby::Engine.subscribe(:sidekiq)
    Sidekiq.configure_server do |config|
      config.server_middleware do |chain|
        chain.add Trifle::Ruby::Middleware::SidekiqJob
      end
    end
  end
end
